pub fn square_of_sum(n: u32) -> u32 {
    (1..=n)
        .fold(0, |acc, v| acc + v)
        .pow(2)
}

pub fn sum_of_squares(n: u32) -> u32 {
    (1..=n)
        .into_iter()
        .map(|v| v.pow(2))
        .fold(0, |acc, v| acc + v)
}

pub fn difference(n: u32) -> u32 {
    let a = sum_of_squares(n);
    let b = square_of_sum(n);
    if a > b {
        a - b
    } else {
        b - a
    }
}

#[test]
#[ignore]
fn difference_5() {
    assert_eq!(170, difference(5));
}